<template>
	<view class="content">
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="info-item" v-for="(item,index) in list" :key="item.id">
					<view class="title-item">
						<view class="name">工作任务</view>
						<view class="total-item">
							<view class="status3" v-if="item.status===1">
								<view class="round"></view>
								<view class="text">已完成</view>
							</view>
							<view class="status2" v-else-if="item.status===2">
								<view class="round"></view>
								<view class="text">未完成</view>
							</view>
							<view class="status" v-else-if="item.status===3">
								<view class="round"></view>
								<view class="text">正在开展</view>
							</view>
						</view>
					</view>
					<view class="text-block">
						<view class="text-content" :class="item.more?'':'fewer'">{{item.task}}</view>
						<view @click="list[index].more=!item.more" class="more">{{item.more?'收起':'展开'}}</view>
					</view>
					<view class="name">进展情况</view>
					<view class="text-block">
						<view class="text-content">{{item.evolve}}</view>
					</view>
				</view>
			</template>
			<view v-else style="text-align: center;">暂无数据</view>
			<!-- <view v-if="list.length>0&&!listConf.more" style="text-align: center;">没有更多了</view> -->
		</view>
	</view>
</template>

<script>
	import {
		isMore
	} from '@/util/util.js'
	import {
		getWorkByIdApi
	} from '@/api/work.js'
	export default {
		data() {
			return {
				id: null,
				list: [],
				listConf: {
					page: 1,
					limit: 10,
					more: true,
				},
			}
		},
		methods: {
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getWorkByIdApi({
					id: this.id
				}).then(data => {
					uni.hideLoading()
					let list = data.list || [];
					list.forEach((item, index) => {
						item.more = false;
					})
					this.list = list;
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		// onReachBottom() {
		// 	if (this.listConf.more) {
		// 		this.listConf.page++;
		// 		this.getList()
		// 	}
		// },
		onLoad(e) {
			this.id = e.id
			uni.setNavigationBarTitle({
				title: e.title
			})
			this.getList(true)
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #F5F5F5;
		width: 100%;
		padding: 30rpx;
		min-height: 100vh;

		.info-block {
			display: flex;
			flex-direction: column;
			height: auto;
			position: relative;


			.info-item {
				width: 100%;
				height: auto;
				box-shadow: 0 0 10px 0 #dedede;
				background: #fff;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				border-radius: 20rpx;
				padding: 30rpx;
				margin-bottom: 30rpx;
				//align-items: center;

				.title-item {
					width: 100%;
					display: flex;
					flex-direction: row;
					justify-content: space-between;

					.name {
						font-weight: bold;
						font-size: 32rpx;
					}

					.total-item {
						display: flex;
						flex-direction: column;
						align-items: center;

						.money {
							font-weight: bold;
							font-size: 34rpx;
						}

						.text {
							font-size: 28rpx;
							color: #999;
							margin-top: 10rpx;
						}

						.status {
							display: flex;
							flex-direction: row;
							align-items: center;

							.round {
								width: 30rpx;
								height: 30rpx;
								border-radius: 50%;
								background-color: #EF731B;
								margin-top: 10rpx;
								margin-right: 10rpx;
							}

							.text {
								font-size: 28rpx;
								color: #EF731B;
								font-weight: 600;
							}
						}

						.status2 {
							display: flex;
							flex-direction: row;
							align-items: center;

							.round {
								width: 30rpx;
								height: 30rpx;
								border-radius: 50%;
								background-color: #E30302;
								margin-top: 10rpx;
								margin-right: 10rpx;
							}

							.text {
								font-size: 28rpx;
								color: #E30302;
								font-weight: 600;
							}
						}

						.status3 {
							display: flex;
							flex-direction: row;
							align-items: center;

							.round {
								width: 30rpx;
								height: 30rpx;
								border-radius: 50%;
								background-color: #029602;
								margin-top: 10rpx;
								margin-right: 10rpx;
							}

							.text {
								font-size: 28rpx;
								color: #029602;
								font-weight: 600;
							}
						}
					}
				}

				.name {
					margin-top: 20rpx;
					font-weight: bold;
					font-size: 32rpx;
				}

				.text-block {
					flex-direction: column;
					color: #000;
					background-color: #F5F5F5;
					padding: 20rpx;
					margin-top: 30rpx;
					border-radius: 20rpx;

					.text-content {
						font-size: 30rpx;
						text-align: justify;
						line-height: 1.8;
					}

					.text-content.fewer {
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 3;
						overflow: hidden;
					}

					.more {
						color: $uni-color-primary;
						font-size: 30rpx;
						text-align: right;
					}
				}
			}
		}
	}
</style>